********************************************************************************
** Do file: g14_endline_income.do
** First started: April 22, 2020 
** Last edited: December 31, 2023

/* Purpose: this do file analyzes effect on adult income

Part I: Effect on adult income

* ITEM MADE: TABLE A.16
*/

********************************************************************************

clear
clear matrix
clear mata
set maxvar 10000

** Preamble - data management for both the individual level dataset and household level dataset **

** Household **

* Load key data first
use "$merged/key_rep.dta", clear
keep if hhid!=.

* Restrict down to sample of interest
keep if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_surveyed==1 & k_surveyed_end==1

* Bring in income variable
merge 1:1 hhid using "$esvy_clean/adult_labor_supply_hh.dta", keepusing(e_adt_lb_inct)
keep if _merge==3 | _merge==1
drop _merge
			
* Drop the choice group as well
drop if treatmenttype_sh=="R T3"

* Develop indicators
g anytreat_assigned = (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") 
g locked_assigned = (treatmenttype_sh=="R T1-L")
g surprise_assigned = (treatmenttype_sh=="R T1-U")
g unlocked_assigned = (treatmenttype_sh=="R T2-U")

* Change several values here to be USD
replace e_adt_lb_inct = e_adt_lb_inct/3704


************
** Part I **
************

***** TABLE A.16 *****

*** Effect on adult income

* Outcome means
sum e_adt_lb_inct if anytreat_assigned!=. & anytreat_assigned==0

reg e_adt_lb_inct locked_assigned surprise_assigned unlocked_assigned
test locked_assigned = unlocked_assigned

* OLS results
eststo: reg e_adt_lb_inct anytreat_assigned
eststo: reg e_adt_lb_inct locked_assigned surprise_assigned unlocked_assigned

esttab using "$tables/income99_lvl_ITT.tex", ///
	b(0) se(0) se replace booktabs star(* .10 ** .05 *** .01) title(Total Household Adult Income\label{income99_lvl_ITT}) ///
	label nodepvars mtitles("Total household adult income" "Total household adult income") nonotes ///
	varlabels(anytreat_assigned "Pooled" locked_assigned "Secured" surprise_assigned "Surprise Unsecured" unlocked_assigned "Unsecured" _cons "Constant", ///
	elist(anytreat_assigned \addlinespace locked_assigned \addlinespace surprise_assigned \addlinespace unlocked_assigned \addlinespace)) 
eststo clear
